<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>分步表单</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="/lib/layui-v2.5.5/css/layui.css" media="all">
    <link rel="stylesheet" href="/css/public.css" media="all">
    <link rel="stylesheet" href="/js/lay-module/step-lay/step.css" media="all">
</head>
<body>
<div class="layuimini-container">
   <!-- <div class="layui-form-item">
        <label class="layui-form-label" style="line-height: 5px">余额:</label>
        <div class="layui-input-inline">
            <span style="color: red" id="balance" ></span>(元)
        </div>

    </div>-->
    <div class="layuimini-main">

        <div class="layui-fluid">
            <div class="layui-card">
                <div class="layui-card-body" style="padding-top: 40px;">
                    <div class="layui-carousel" id="stepForm" lay-filter="stepForm" style="margin: 0 auto;">
                        <div carousel-item>
                            <div>
                                <form class="layui-form" style="margin: 0 auto;max-width: 460px;padding-top: 40px;">
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">提现金额:</label>
                                        <div class="layui-input-inline">
                                            <input type="text" name="money" autocomplete="off" class="layui-input">
                                        </div>
                                        <span style="color: red ;font-size: 12px;line-height: 3">提现金额不能大于余额*</span>
                                    </div>

                                    <div class="layui-form-item">
                                        <label class="layui-form-label">银行所在地址及支行详细名称:</label>
                                        <div class="layui-input-inline">
                                            <input type="text" name="address" autocomplete="off" class="layui-input">
                                        </div>
                                        <span style="color: red ;font-size: 12px;line-height: 3">*</span>
                                    </div>

                                    <div class="layui-form-item">
                                        <label class="layui-form-label">选择银行</label>
                                        <div class="layui-input-inline">
                                            <select id="bank" name="bank" lay-verify="required" lay-search="">
                                                <option value="0">请选择</option>
                                                <option value="1">中国银行</option>
                                                <option value="2">交通银行</option>
                                                <option value="3">建设银行</option>

                                            </select>
                                        </div>
                                        <span style="color: red ;font-size: 12px;line-height: 3">*</span>
                                    </div>



                                    <div class="layui-form-item">
                                        <label class="layui-form-label">银行开户名:</label>
                                        <div class="layui-input-inline">
                                            <input type="text" name="bankName" autocomplete="off" class="layui-input">
                                        </div>
                                        <span style="color: red ;font-size: 12px;line-height: 3">*</span>
                                    </div>

                                    <div class="layui-form-item">
                                        <label class="layui-form-label">银行卡号:</label>
                                        <div class="layui-input-inline">
                                            <input type="text" name="card" autocomplete="off" class="layui-input">
                                        </div>
                                        <span style="color: red ;font-size: 12px;line-height: 3">*</span>

                                    </div>

                                    <div class="layui-form-item">
                                        <div class="layui-input-block">
                                            <button class="layui-btn" lay-submit lay-filter="formStep">
                                                &emsp;下一步&emsp;
                                            </button>
                                        </div>
                                    </div>
                                </form>
                            </div>
                            <div>
                                <form class="layui-form" style="margin: 0 auto;max-width: 460px;padding-top: 40px;">
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">提现金额:</label>
                                        <div class="layui-input-inline">
                                            <input type="text" id="mon" autocomplete="off" class="layui-input">
                                        </div>

                                    </div>

                                    <div class="layui-form-item">
                                        <label class="layui-form-label">银行所在地址及支行详细名称:</label>
                                        <div class="layui-input-inline">
                                            <input type="text" id="address1" autocomplete="off" class="layui-input">
                                        </div>

                                    </div>

                                    <div class="layui-form-item">
                                        <label class="layui-form-label">选择银行</label>
                                        <div class="layui-input-inline">
                                            <input type="text" id="bank1" autocomplete="off" class="layui-input">
                                        </div>

                                    </div>



                                    <div class="layui-form-item">
                                        <label class="layui-form-label">银行开户名:</label>
                                        <div class="layui-input-inline">
                                            <input type="text" id="bankName1" autocomplete="off" class="layui-input">
                                        </div>

                                    </div>

                                    <div class="layui-form-item">
                                        <label class="layui-form-label">银行卡号:</label>
                                        <div class="layui-input-inline">
                                            <input type="text" id="card1" autocomplete="off" class="layui-input">
                                        </div>


                                    </div>
                                    <div class="layui-form-item">
                                        <div class="layui-input-block">
                                            <button type="button" class="layui-btn layui-btn-primary pre">上一步</button>
                                            <button class="layui-btn" lay-submit lay-filter="formStep2">
                                                &emsp;确认入款&emsp;
                                            </button>
                                        </div>
                                    </div>
                                </form>
                            </div>
                            <div>
                                <div style="text-align: center;margin-top: 90px;">
                                    <i class="layui-icon layui-circle"
                                       style="color: white;font-size:30px;font-weight:bold;background: #52C41A;padding: 20px;line-height: 80px;">&#xe605;</i>
                                    <div style="font-size: 24px;color: #333;font-weight: 500;margin-top: 30px;">
                                        申请中......
                                    </div>
                                    <div style="font-size: 14px;color: #666;margin-top: 20px;">预计两小时到账</div>
                                </div>
                                <div style="text-align: center;margin-top: 50px;">
                                    <button class="layui-btn next">再入一笔</button>
                                </div>
                            </div>
                        </div>
                    </div>
                    <hr>
                </div>
            </div>
        </div>

    </div>
</div>
<script src="/lib/layui-v2.5.5/layui.js" charset="utf-8"></script>
<script src="/js/lay-config.js?v=1.0.4" charset="utf-8"></script>

<script>

    layui.use([ 'form', 'step'], function () {
        var $ = layui.jquery;
            form = layui.form;
            step = layui.step;

        step.render({
            elem: '#stepForm',
            filter: 'stepForm',
            width: '100%', //设置容器宽度
            stepWidth: '750px',
            height: '500px',
            stepItems: [{
                title: '填写入款信息'
            }, {
                title: '确认入款信息'
            }, {
                title: '完成'
            }]
        });


        // $.ajax({
        //     url:"/bank/findList.do",
        //     type:"get",
        //     dataType:"json",
        //     data:{
        //         page:0,
        //         limit:0,
        //     },
        //     success:function (r) {
        //         var data = r.data;
        //         $("#balance").html(data[0].balance)
        //
        //     }
        // })

        form.on('submit(formStep)', function (data) {
            step.next('#stepForm');
            var money = $("input[name='money']").val();
            $("#mon").val(money)

            var address = $("input[name='address']").val();
            $("#address1").val(address)

            var bankName = $("input[name='bankName']").val();
            $("#bankName1").val(bankName)

            var type = $("#bank option:selected").val();
            $("#bank1").val(type)

            var card = $("input[name='card']").val();
            $("#card1").val(card)
            return false;
        });

        $('.pre').click(function () {
            step.pre('#stepForm');

        });

        $('.next').click(function () {
            step.next('#stepForm');
        });
        form.on('submit(formStep2)', function (data) {
            var date = $("input[name='date']").val();
            var money = $("input[name='money']").val();
            var type = $("#type option:selected").val();

            $.ajax({
                url: "/bank/findList.do",
                type: "get",
                dataType: "json",
                async: false,
                data:{
                    page:0,
                    limit:0,
                },
                success: function (r) {
                    var data = r.data;
                    if(money>data[0].balance){
                        alert("提现金额不能大于余额")
                    }else {
                        $.ajax({
                            url:"/bank/addOut.do",
                            data:{
                                moneyOut:money,
                                balance:money,
                            },
                            type:"get",
                            dataType:"json",
                            async:false,
                            success:function (rec) {
                                if(rec.code==0){
                                    alert("汇款成功")
                                }else {
                                    alert("汇款失败")
                                }
                            },
                        })
                        step.next('#stepForm');
                    }

                }
            })
           return false;
        });
    })


</script>
</body>
</html>